import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
import login from "../views/login";
import product from "../views/product/product.vue";
import productEnvironmental from "../views/product/productEnvironmental.vue";
import productHydraulic from "../views/product/productHydraulic.vue";
import productJianZhu from "../views/product/productJianZhu.vue";
import productNature from "../views/product/productNature.vue";
import productPublic from "../views/product/productPublic.vue";
import productTraffic from "../views/product/productTraffic.vue";
import publicPage from "../views/publicPage.vue";
import Solution from "../views/Solution/Solution.vue";

import SolutionCity from "../views/Solution/SolutionCity.vue";
import SolutionElse from "../views/Solution/SolutionElse.vue";
import SolutionEmergencies from "../views/Solution/SolutionEmergencies.vue";
import SolutionExhibition from "../views/Solution/SolutionExhibition.vue";
import SolutionHydroelectric from "../views/Solution/SolutionHydroelectric.vue";
import SolutionMinistry from "../views/Solution/SolutionMinistry.vue";
import SolutionPubic from "../views/Solution/SolutionPubic.vue";
import SolutionResource from "../views/Solution/SolutionResource.vue";
import SolutionTraffic from "../views/Solution/SolutionTraffic.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
  },
  {
    path: "/Home",
    name: "Home",
    component: Home,
  },
  {
    path: "/login",
    name: "login",
    component: login,
  },
  {
    path: "/publicPage",
    name: "publicPage",
    component: publicPage,
  },
  {
    path: "/product",
    name: "product",
    component: product,
    redirect: "/product/productPublic", // 设置默认打开的页面
    children: [
      {
        path: "productEnvironmental",
        name: "productEnvironmental",
        component: productEnvironmental,
      },

      {
        path: "productHydraulic",
        name: "productHydraulic",
        component: productHydraulic,
      },
      {
        path: "productPublic",
        name: "productPublic",
        component: productPublic,
      },
      {
        path: "productJianZhu",
        name: "productJianZhu",
        component: productJianZhu,
      },
      {
        path: "productNature",
        name: "productNature",
        component: productNature,
      },
      {
        path: "productTraffic",
        name: "productTraffic",
        component: productTraffic,
      },
    ],
  },

  {
    path: "/solution",
    name: "solution",
    component: Solution,
    redirect: "/solution/SolutionPubic", // 设置默认打开的页面
    children: [
      {
        path: "SolutionElse",
        name: "SolutionElse",
        component: SolutionElse,
      },
      {
        path: "SolutionEmergencies",
        name: "SolutionEmergencies",
        component: SolutionEmergencies,
      },
      {
        path: "SolutionPubic",
        name: "SolutionPubic",
        component: SolutionPubic,
      },
      {
        path: "SolutionExhibition",
        name: "SolutionExhibition",
        component: SolutionExhibition,
      },
      {
        path: "SolutionHydroelectric",
        name: "SolutionHydroelectric",
        component: SolutionHydroelectric,
      },

      {
        path: "SolutionResource",
        name: "SolutionResource",
        component: SolutionResource,
      },
      {
        path: "SolutionMinistry",
        name: "SolutionMinistry",
        component: SolutionMinistry,
      },

      {
        path: "SolutionCity",
        name: "SolutionCity",
        component: SolutionCity,
      },
      {
        path: "SolutionTraffic",
        name: "SolutionTraffic",
        component: SolutionTraffic,
      },
    ],
  },
];

const router = new VueRouter({
  routes,
});
// // 路由守卫
// router.beforeEach((to, from, next) => {
//   if (to.matched.some(res => res.meta.isLogin)) {
//     //判断是否需要登录
//     if (localStorage["token"]) {
//       next();
//     } else {
//       next({
//         path: "/login",
//       });
//     }
//   } else {
//     next();
//   }
// });

export default router;
